<div class="container-fluid">
  <div class="row">
    <div class="col-sm-2">
      <%= render "shared/sidenav" %>

    </div>
    <div class="col-sm-10">
      <div class="panel panel-primary">
        <div class="panel-heading">
          <% if teacher_logged_in? %><h3 class="panel-title">成绩管理: <%=@course.name%></h3><% end %>
          <% if student_logged_in? %><h3 class="panel-title">成绩列表</h3><% end %>
        </div>
        <div class="panel-body" style="min-height: 450px">
          <table class="table table-striped table-hover">
            <thead>

            <tr>
              <th>学号</th>
              <th>名字</th>
              <th>专业</th>
              <th>培养单位</th>
              <th>课程</th>
              <th>目前分数</th>

            </tr>
            </thead>
            <tbody>

            <% @grades.each do |grade| %>
                <tr>
                  <td><%= grade.user.num %></td>
                  <td><%= grade.user.name %></td>
                  <td><%= grade.user.major %></td>
                  <td><%= grade.user.department %></td>
                  <td><%= grade.course.name %></td>
                  <td><%= grade.grade %></td>

                  <% if teacher_logged_in? %>
                      <%= form_for grade, url: grade_url(id: grade.id, course_id: grade.course.id), method: :patch do |f| %>
                          <td><%= f.text_field :grade %></td>
                          <td><%= f.submit "提交", class: "btn btn-success btn-xs" %></td>
                      <% end %>
                  <% end %>

                </tr>
            <% end %>
            </tbody>
          </table>
          <%= will_paginate @grades %>
        </div>
      </div>
    </div>
  </div>
</div>


